<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('巡视记录列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row" id="printArea">
        <div class="col-sm-12 search-collapse hidden">
            <form id="formId">
                <div class="select-list">
                    <input hidden="hidden" name="orderId" th:value="${orderId}"/>

                    <ul>
                        <!--  <li>
                              巡视类型 1:牛舍 2：鸡舍：<input type="text" name="xsType"/>
                          </li>

                          <li>
                              状态:1：待确认2：已确认：<input type="text" name="xsStatus"/>
                          </li>

                          <li>
                              订单id：<input type="text" name="orderId"/>
                          </li>

                          <li>
                              鸡舍号：<input type="text" name="roomNum"/>
                          </li>

                          <li>
                              存栏数量：<input type="text" name="stockAmount"/>
                          </li>

                          <li>
                              巡视数量：<input type="text" name="xsAmount"/>
                          </li>

                          <li>
                              巡视人员：<input type="text" name="createBy"/>
                          </li>

                          <li>
                              巡视时间：<input type="text" name="createTime"/>
                          </li>

                          <li>
                              备注：<input type="text" name="remark"/>
                          </li>-->

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">

            <!-- <a class="btn btn-primary " onclick="openOrder()">
                 <i class="fa fa-table"></i> 巡视记录单
             </a>


              <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:ncXunshiLogs:edit">
                 <i class="fa fa-edit"></i> 修改
             </a>


             <a class="btn btn-warning" onclick="confirmTable();">
                 <i class="fa fa-send"></i> 单据确认
             </a>

             <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncXunshiLogs:add">
                 <i class="fa fa-plus"></i> 添加
             </a>
               <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:ncXunshiLogs:remove">
              <i class="fa fa-remove"></i> 删除
             </a>    -->
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:ncXunshiLogs:export">
                <i class="fa fa-download"></i> 导出
            </a>-->
        </div>
        <h3 align="center"> <span th:text="鸡舍巡视" id="ordercode" hidden="hidden"></span> </h3>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
            <h3> <span class="fl-l" id="autograph" hidden="hidden"></span> </h3>
        </div>

        <div class="btn-group-sm" id="toolbar1" role="group">

            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
            <a class="btn btn-warning" id="print-btn" orderType = "19">
                <i class="fa fa-download"></i> 打印
            </a>
            <!--            <div></div>-->
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncXunshiLogs:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncXunshiLogs:remove')}]];
    var prefix = ctx + "system/ncXunshiLogs/chicken";

    $(function () {
        var options = {
            url: prefix + "/list/2/4?orderId="+[[${orderId}]],
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "巡视记录",
            showExport: false,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            toolbar: 'toolbar1',
            columns: [
               /* {
                checkbox: true
            },*/
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'xsId',
                    title: '巡视id',
                    visible: false
                },
                {
                    field: 'xsType',
                    title: '巡视类型',
                    sortable: true,
                    visible: false

                },
                {
                    field: 'xsStatus',
                    title: '状态:1：待确认 2：已挂起 3：已确认：4：已生成订单',
                    sortable: true,
                    visible: false

                },
                /*{
                    field : 'orderId',
                    title : '订单id',
                    sortable: true
                },*/
                {
                    field: 'roomNum',
                    title: '鸡舍号',
                    sortable: true
                },
                {
                    field: 'stockAmount',
                    title: '存栏数量',
                    sortable: true
                },
                {
                    field: 'xsAmount',
                    title: '巡视数量',
                    sortable: true
                },
                {
                    field: 'createBy',
                    title: '巡视人员',
                    sortable: true
                },
                {
                    field: 'createTime',
                    title: '巡视时间',
                    sortable: true
                },
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.xsId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.xsId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /*打开检测记录单*/
    function openOrder() {
        var url = ctx + 'system/ncOrder?orderType=19';
        $.modal.openTab("巡视鸡舍记录单", url);
    }


    /*表单确认*/
    function confirmTable() {
        var confirmTable = prefix + "/confirmTable";
        var data = $('#bootstrap-table').bootstrapTable('getData');
        if (data && data.length > 0) {
            $.modal.confirm("确认生成巡视单吗？", function () {
                var ids = [];
                $(data).each(function (i, e) {
                    ids.push(e.xsId);
                });
                var ids_str = ids.join(",");
                myPost(confirmTable, {
                        ids: ids_str
                    },
                    function (data) {

                        if (data.code == 0) {
                            layer.msg("提交成功")
                        } else {
                            layer.msg(data.msg);
                        }
                        // reload()
                    }, function (e) {
                        layer.msg("确认失败!");
                        // reload()
                    })

            })
        } else {
            layer.msg("未发现数据!")
        }

    }

    //刷新页面
    function reload() {
        window.location.reload()
    }
</script>
</body>
</html>